import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

// deletes all reservations with guestName "Adam Confino" in the database

public class SqlTest6
{
	
	  public static void main(String args[]) throws SQLException {
	
		  Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/bedandbreakfast",
					  "root", "");	
			
		  try{
		        Statement st = con.createStatement();
		        String sql = "DELETE FROM reservation WHERE guestName='Adam Confino'";
		        int delete = st.executeUpdate(sql);

//TODO    fix logic so statement reflects every time a reservation has been deleted
		        
		        if(delete == 1){
		          System.out.println("Reservation has been deleted.");
		        }
		        else{
		          System.out.println("Reservation was not deleted.");
		        }
		      }
		      catch (SQLException s){
		        System.out.println("SQL statement is not executed!");
		      }
		      
		}

}
